home *** CD-ROM | disk | FTP | other *** search
- ;void print(strg);
- ; char *strg;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _time_out:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _print
- _print proc near
- jmp short start ;jmp over local data
- delay dw ? ;
- target dw ? ;
- start: push bp ;
- mov bp,sp ;set stack frame
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;save DS
- mov ah,1 ;BIOS func to init prtr
- mov dx,0 ;choose LPT1
- int 17h ;initialize the prtr port
- sub ax,ax ;clear AX
- mov es,ax ;pt ES to 0000:0000
- mov dx,es:[408H] ;get LPT1 base address
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- jmp short L00 ;
- L0: mov si,[bp+4] ;near case
- L00: mov al,_time_out ;get _time_out seconds
- or al,al ;don't allow zero seconds
- jnz L1 ;
- mov al,3 ;default to 3 seconds
- L1: mov cl,18 ;18 ticks per second
- mul cl ;
- mov cs:delay,ax ;save count
- cmp byte ptr[si],0 ;test for null string
- je L4 ;quit if null
- L2: mov al,[si] ;mov character to AL
- inc si ;forward ptr for next time
- cmp al,0 ;end of string?
- je L4 ;
- out dx,al ;send to output data register
- inc dx ;forward to status register
- push cx ;save string counter
- call GetBiosCount ;get timer reading
- mov bx,cx ;make copy
- add cx,cs:delay ;add delay count
- cmp bx,cx ;if timer doesn't turn over...
- jb L3 ;go ahead
- mov cx,cs:delay ;otherwise, extend delay
- L3: mov cs:target,cx ;save target count on stack
- Wait: in al,dx ;get status value
- test al,8 ;test for printer error
- jz KN ;
- test al,80h ;test for printer Ready
- jnz Ready ;jump if ready
- KN: call GetBiosCount ;
- cmp cx,cs:target ;compare to target
- jb Wait ;
- mov bl,1 ;1 = error
- pop cx ;restore string counter
- jmp short L5 ;go quit routine
- Ready: pop cx ;restore string counter
- inc dx ; output control register
- mov al,13 ;bits for strobe signal
- out dx,al ;send the signal
- dec al ;change to strobe OFF
- out dx,al ;send the signal
- dec dx ;point back to
- dec dx ; base address
- jmp short L2 ;loop
- L4: mov bl,0 ;0 = no error
- L5: pop ds ;restore DS
- mov _error_code,bl ;set _error_code
- pop si ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- GetBIOSCount PROC
- push dx ;return value in CX:DX
- push ax ;
- sub ah,ah ;function number
- int 1ah ;get timer count
- mov cx,dx ;low word in CX
- pop ax ;
- pop dx ;
- ret
- GetBIOSCount endp
- _print endp
- _TEXT ENDS
- END